Java Testing with Selenium by Sujay Raghavendra

Java Testing with Selenium by Sujay Raghavendra
Author: Sujay Raghavendra
Language: eng
Format: epub
ISBN: 9798868802911
Publisher: Apress

Selecting and Deselecting Options with MultiSelectList


A MultiSelectList element lets you select and deselect multiple options. Let’s discuss how to interact with them using Selenium.

Selecting Multiple Options


The Select class interacts with a SelectList element and selects multiple options by visible text, value, or index.Select languagesSelectList = new Select(driver.findElement(By.id("languages")));

languagesSelectList.selectByVisibleText("Java");

languagesSelectList.selectByValue("python");

languagesSelectList.selectByIndex(2); // 0-based index, selects "JavaScript"